package cn.wolfcode.p2p.mgrsite.web.controller;

import cn.wolfcode.p2p.base.domain.RealAuth;
import cn.wolfcode.p2p.base.query.RealAuthQuery;
import cn.wolfcode.p2p.base.service.IRealAuthService;
import cn.wolfcode.p2p.base.util.JSONResult;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

// 后台认证信息
@Controller
public class RealAuthController {

    @Autowired
    private IRealAuthService realAuthService;

    // 身份认证的列表
    @RequestMapping("/realAuth")
    @RequiresPermissions(value = {"身份认证列表", "realAuth"}, logical = Logical.OR)
    public String toRealAuth(Model model, @ModelAttribute("qo") RealAuthQuery qo){
        // 按申请时间倒排序
        qo.setGroupType("apply_time desc");

        model.addAttribute("pageInfo", realAuthService.query(qo));
        return "realAuth/list";
    }

    // 身份认证审核
    @RequestMapping("/realAuth_audit")
    @ResponseBody
    @RequiresPermissions(value = {"身份认证审核", "realAuth_audit"}, logical = Logical.OR)
    public JSONResult auditRealAuth(RealAuth vo){

        realAuthService.auditRealAuth(vo);
        return new JSONResult();
    }
}
